package com.qax.task.timer.core;


import com.qax.task.logger.Logger;
import com.qax.task.logger.LoggerFactory;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;

/**
 * @author lianglei
 */
public class EmailJob {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @JobHanlder(
            type = "jcq",
            applicationName ="email-application")
    public Integer  sendEmailForjack(){
        logger.info("send email for jack!!!!\t");
        return 1 ;
    }


    @JobHanlder(
            type = "jcq",
            applicationName ="email-application")
    public Integer  sendEmailForlina(String lina){
        logger.info("send email for lina!!!!\t" + lina);
        return 1 ;
    }

//    public static EtcdClient etcdClient = EtcdClientFactory.getInstance().connect("-config",
//            "http://10.47.140.59:2379",
//                                         true,
//                false);
    public static void main(String[] args) throws Exception {
//       etcdClient.putKey("/jcq/email-application/GROUP_NAME/94098077-3e2c-46b1-8d40-26cbf62a2cd0/command/",
//                "{ \t\"jobId\" : \"94098077-3e2c-46b1-8d40-26cbf62a2cd0\", \t\"executorFailRetryCount\" :\"3\", \t\"triggerTime\":\"1000\", \t\"triggerMsg\":\"hello\" }");
//
//        etcdClient.putKey("/jcq/email-application/GROUP_NAME/48b2f8f5-9c22-4437-8584-3e0ee2fab700/command/",
//                "{ \t\"jobId\" : \"48b2f8f5-9c22-4437-8584-3e0ee2fab700\", \t\"executorFailRetryCount\" :\"3\", \t\"triggerTime\":\"5000\", \t\"triggerMsg\":\"hello\" }");
////        CompletableFuture.runAsync(()->{System.out.println(1212121);});
////        Thread.sleep(5000);
////        etcdClient.getKey("/jcq/email-application/GROUP_NAME/94098077-3e2c-46b1-8d40-26cbf62a2cd0/command/");
//        String s = new String(etcdClient.getKey("/jcq/email-application/GROUP_NAME/48b2f8f5-9c22-4437-8584-3e0ee2fab700/status/").getValue().getBytes());
//        if (s.equals(JobStatus.FINISHED.toString())){
//            etcdClient.putKey("/jcq/email-application/GROUP_NAME/48b2f8f5-9c22-4437-8584-3e0ee2fab700/status/",JobStatus.RUN.toString());
//        }

        HttpResponse<String> response = Unirest.
                put("http://localhost:8081/update/info/by/5/94098077-3e2c-46b1-8d40-26cbf62a2cd0/").asString();

        System.out.println(response);

    }
}
